package com.woniu.carrent.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.carrent.pojo.TCardetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TCardetailMapper extends BaseMapper<TCardetail> {
    @Select("select * from t_cardetail c\n" +
            "join t_energe e on c.energyId = e.energeId\n" +
            "join t_gear g on c.gearId = g.gearId\n" +
            "where c.carId=#{carId}")
    @Results(id = "cardetailMap", value = {
            @Result(id = true, column = "cdId", property = "cdid"),
            @Result(column = "productYear", property = "productyear"),
            @Result(column = "level", property = "level"),
            @Result(column = "seats", property = "seats"),
            @Result(column = "doors", property = "doors"),
            @Result(column = "energyId", property = "energyid"),
            @Result(column = "energyName", property = "energyName"),
            @Result(column = "gearId", property = "gearid"),
            @Result(column = "gearName", property = "gearName"),
            @Result(column = "displacement", property = "displacement"),
            @Result(column = "drive", property = "drive"),
            @Result(column = "upWindow", property = "upwindow"),
            @Result(column = "radar", property = "radar"),
            @Result(column = "gps", property = "gps"),
            @Result(column = "carId", property = "carid"),
            @Result(column = "lisence", property = "lisence"),
            @Result(column = "fsfile", property = "fsfile"),
            @Result(column = "isDeleted", property = "isdeleted"),
            @Result(column = "isOnline", property = "isonline"),
            @Result(column = "userId", property = "userid"),
            @Result(column = "plate", property = "plate"),
            @Result(column = "cdId", property = "photos",
                    many = @Many(select = "com.woniu.carrent.mapper.TCarphotoMapper.selectcarphoto"))
    })
    List<TCardetail> selectcardetail(Integer carId);
    @Delete("delete from t_cardetail where carId=#{carId}")
    int deleteByCarId(Integer carId);
}
